home *** CD-ROM | disk | FTP | other *** search
/ Aminet 32 / Aminet 32 (1999)(Schatztruhe)[!][Aug 1999].iso / Aminet / dev / lang / Python151_Src.lha / Python1.5_Source / Include / structmember.h < prev    next >
C/C++ Source or Header  |  1996-10-25  |  3KB  |  102 lines

  1. #ifndef Py_STRUCTMEMBER_H
  2. #define Py_STRUCTMEMBER_H
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6.  
  7. /***********************************************************
  8. Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam,
  9. The Netherlands.
  10.  
  11.                         All Rights Reserved
  12.  
  13. Permission to use, copy, modify, and distribute this software and its
  14. documentation for any purpose and without fee is hereby granted,
  15. provided that the above copyright notice appear in all copies and that
  16. both that copyright notice and this permission notice appear in
  17. supporting documentation, and that the names of Stichting Mathematisch
  18. Centrum or CWI or Corporation for National Research Initiatives or
  19. CNRI not be used in advertising or publicity pertaining to
  20. distribution of the software without specific, written prior
  21. permission.
  22.  
  23. While CWI is the initial source for this software, a modified version
  24. is made available by the Corporation for National Research Initiatives
  25. (CNRI) at the Internet address ftp://ftp.python.org.
  26.  
  27. STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH
  28. REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
  29. MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH
  30. CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
  31. DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  32. PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  33. TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  34. PERFORMANCE OF THIS SOFTWARE.
  35.  
  36. ******************************************************************/
  37.  
  38. /* Interface to map C struct members to Python object attributes */
  39.  
  40. #ifdef HAVE_STDDEF_H
  41. #include <stddef.h> /* For offsetof */
  42. #endif
  43.  
  44. /* The offsetof() macro calculates the offset of a structure member
  45.    in its structure.  Unfortunately this cannot be written down
  46.    portably, hence it is provided by a Standard C header file.
  47.    For pre-Standard C compilers, here is a version that usually works
  48.    (but watch out!): */
  49.  
  50. #ifndef offsetof
  51. #define offsetof(type, member) ( (int) & ((type*)0) -> member )
  52. #endif
  53.  
  54. /* An array of memberlist structures defines the name, type and offset
  55.    of selected members of a C structure.  These can be read by
  56.    PyMember_Get() and set by PyMember_Set() (except if their READONLY flag
  57.    is set).  The array must be terminated with an entry whose name
  58.    pointer is NULL. */
  59.  
  60. struct memberlist {
  61.     char *name;
  62.     int type;
  63.     int offset;
  64.     int readonly;
  65. };
  66.  
  67. /* Types */
  68. #define T_SHORT        0
  69. #define T_INT        1
  70. #define T_LONG        2
  71. #define T_FLOAT        3
  72. #define T_DOUBLE    4
  73. #define T_STRING    5
  74. #define T_OBJECT    6
  75. /* XXX the ordering here is weird for binary compatibility */
  76. #define T_CHAR        7    /* 1-character string */
  77. #define T_BYTE        8    /* 8-bit signed int */
  78. /* unsigned variants: */
  79. #define T_UBYTE        9
  80. #define T_USHORT    10
  81. #define T_UINT        11
  82. #define T_ULONG        12
  83.  
  84. /* Added by Jack: strings contained in the structure */
  85. #define T_STRING_INPLACE    13
  86. #ifdef macintosh
  87. #define T_PSTRING    14    /* macintosh pascal-style counted string */
  88. #define T_PSTRING_INPLACE    15
  89. #endif /* macintosh */
  90.  
  91. /* Readonly flag */
  92. #define READONLY    1
  93. #define RO        READONLY        /* Shorthand */
  94.  
  95. PyObject *PyMember_Get Py_PROTO((char *, struct memberlist *, char *));
  96. int PyMember_Set Py_PROTO((char *, struct memberlist *, char *, PyObject *));
  97.  
  98. #ifdef __cplusplus
  99. }
  100. #endif
  101. #endif /* !Py_STRUCTMEMBER_H */
  102.